<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>工作审批(纪检)</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style type="text/css">
        .layui-disabled, .layui-disabled:hover {
            color: #000000 !important;
            cursor: not-allowed !important;
        }

        .layui-form-label {
            width: 100px;
        }

        .layui-input-block {
            margin-left: 130px;
        }

        .layui-input layui-unselect {
            cursor: pointer;
        }

        .layui-table {
            width: 96%;
        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row  layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <div class="panel panel-default operation" hidden>
                        <div class="panel-heading title"></div>
                        <div class="layui-tab">
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-card-body">
                                        <form class="layui-form" action="" lay-filter="info">
                                            <input name="_tabKey" id="_tabKey" hidden>
                                            <input name="_jcajxxuuid" id="_jcajxxuuid" hidden>
                                            <input name="_logid" id="_logid" hidden>

                                            <div id="inspectionHearInfo">
                                                <fieldset class="layui-elem-field layui-field-title"
                                                          style="margin-top: 10px;">
                                                    <legend id="jcajbh"></legend>
                                                </fieldset>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">案件名称</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="ajmc" name="ajmc"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>

                                                    <label class="layui-form-label">检查项目</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="jcxm" name="jcxm"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">检查人</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="jcry" name="jcry"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">纳税人名称</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="nsrmc" name="nsrmc"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>
                                                    <label class="layui-form-label">纳税人识别号</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="nsrsbh" name="nsrsbh"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>
                                                </div>

                                            </div>
                                            <div id="denoWorkDiv">
                                                <fieldset class="layui-elem-field layui-field-title"
                                                          style="margin-top: 10px;">
                                                    <legend>完成工作</legend>
                                                </fieldset>

                                                <div class="layui-form-item">
                                                    <div class="layui-input-block">
									<textarea disabled="ture" rows="2" name="content1" id="content1"
                                              placeholder="请输入反馈信息,1-500个字符" autocomplete="off"
                                              class="layui-textarea layui-disabled"
                                              onkeyup="javascript:texLength1(this, 'textarea_length1');"></textarea>
                                                        <span class="red" id="textarea_length1">0</span> / <span
                                                            class="num_count1">500</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="content2and3Div">

                                            </div>

                                            <fieldset class="layui-elem-field layui-field-title" id="bottomLine"
                                                      style="margin-top: 10px;">
                                                <legend>纪检审批</legend>
                                            </fieldset>

                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
									<textarea rows="2" name="disciplineContent" id="disciplineContent"
                                              placeholder="请输入,1-500个字符" autocomplete="off"
                                              class="layui-textarea"
                                              onkeyup="javascript:texLength1(this, 'textarea_length1');"></textarea>
                                                    <span class="red" id="textarea_length1">0</span> / <span
                                                        class="num_count1">500</span>
                                                </div>
                                            </div>

                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button type="submit" class="layui-btn" id="saveWorkflowLog"
                                                            onclick="return false" lay-submit
                                                            lay-filter="saveWorkflowLog">提交
                                                    </button>
                                                    <button class="layui-btn layui-btn-primary" id="btn_cancel">返回
                                                    </button>
                                                </div>

                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab table_div">
                        <ul class="layui-tab-title">
                            <li class="layui-this" id="wait">未审核</li>
                            <li id="deno">已审核</li>
                        </ul>

                        <div class="layui-tab-content">

                            <div class="layui-tab-item layui-show">
                                <div id="searchParam">
                                    <div class="layui-form-item">
                                    </div>
                                    <table class="layui-table" id="waitShowTable" lay-filter="waitShowTable"></table>
                                </div>
                            </div>

                            <div class="layui-tab-item">
                                <div id="searchParam">
                                    <div class="layui-form-item">
                                    </div>
                                    <table class="layui-table" id="denoShowTable" lay-filter="denoShowTable"></table>
                                </div>
                            </div>

                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="waittool">
    <a class="layui-btn layui-btn-xs" lay-event="discipline">纪检审批</a>
</script>

<script type="text/html" id="denotool">
    <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
</script>

<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="none">

    // 获取token
    var token = CoreUtil.getData("access_token");
    // 地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");

    var waitShowTable;
    var denoShowTable;

    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var upload = layui.upload;
    var element = layui.element;
    var maxlength = 500;
    var inspectionMan = "";
    var meetMan = "";
    var contentdate = null;

    layui.use(['table', 'layer', 'laydate', 'upload', 'element'], function () {

        waitShowTable = table.render({
            elem: '#waitShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/log/listbydiscipline' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },
            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'id',
                    title: '日志编号',
                    sort: true,
                    hide: true
                }, {
                    align: 'center',
                    width: 168,
                    field: 'createId',
                    title: '填报人',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'type',
                    title: '日志类型',
                    sort: true,
                    templet: function (item) {
                        if (item.type == "1") {
                            return "日常日志";
                        } else if (item.type == "2") {
                            return "案件日志";
                        } else {
                            return "未知：" + item.type;
                        }
                    }
                }, {
                    align: 'center',
                    width: 158,
                    field: 'contentdate',
                    title: '日志日期',
                    sort: true, templet: function (d) {
                        if (!d.contentdate) {
                            return '';
                        }
                        return layui.util.toDateString(d.contentdate, 'yyyy-MM-dd');
                    }
                }, {
                    align: 'center',
                    width: 218,
                    field: 'nsrmc',
                    title: '纳税人名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 218,
                    field: 'nsrsbh',
                    title: '纳税人识别号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 518,
                    field: 'content1',
                    title: '完成工作',
                    sort: true,
                }, {
                    fixed: 'right',
                    align: 'center',
                    width: 95,
                    toolbar: "#waittool",
                    title: '操作'
                }
            ]],
            toolbar: '#toolbar'
        });

        // 列操作
        table.on('tool(waitShowTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'discipline':
                    view("0", data);
                    break;
            }
        });

        denoShowTable = table.render({
            elem: '#denoShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/log/listbydisciplinedeno' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },

            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'id',
                    title: '日志编号',
                    sort: true,
                    hide: true
                }, {
                    align: 'center',
                    width: 158,
                    field: 'type',
                    title: '日志类型',
                    sort: true,
                    templet: function (item) {
                        if (item.type == "1") {
                            return "日常日志";
                        } else if (item.type == "2") {
                            return "案件日志";
                        } else {
                            return "未知：" + item.type;
                        }
                    }
                }, {
                    align: 'center',
                    width: 158,
                    field: 'createId',
                    title: '日志填写人',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'contentdate',
                    title: '日志日期',
                    sort: true,
                }, {
                    align: 'center',
                    width: 218,
                    field: 'nsrmc',
                    title: '纳税人名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 218,
                    field: 'nsrsbh',
                    title: '纳税人识别号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 518,
                    field: 'content1',
                    title: '完成工作',
                    sort: true,
                }, /* {
							align : 'center',
							width : 218,
							field : 'content2',
							title : '发现问题',
							sort : true,
						}, {
							align : 'center',
							width : 218,
							field : 'content3',
							title : '下步打算',
							sort : true,
						}, */ {
                    align: 'center',
                    width: 168,
                    field: 'createTime',
                    title: '创建日期',
                    sort: true,
                }
            ]],
            toolbar: '#logToolbar'
        });

        // 列操作
        table.on('tool(denoShowTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'view':
                    view("1", data);
                    break;
            }
        });

        // 返回
        $("#btn_cancel").click(function () {
            back();
            return false;
        });

        $("#wait").click(function () {
            waitSearch();
        });

        $("#deno").click(function () {
            denoSearch();
        });

        form.on('submit(saveWorkflowLog)', function (data) {


            var disciplineContent = $("#disciplineContent").val();
            if (CoreUtil.isEmpty(disciplineContent)) {
                layer.msg("【纪检审批】内容未填写！");
                return false;
            }

            var mapArr = {
                disciplineContent: disciplineContent,
                id: $("#_logid").val()
            };
            var url = "/workflow/log/adddiscipline";
            CoreUtil.sendPost(url, mapArr, function (res) {
                if (res.code == '0') {
                    layer.msg("纪检审批成功！");
                    back();
                } else {
                    layer.msg(res.msg);
                    return false;
                }
            });

        });
    });

    // 执行查询
    function waitSearch() {
        waitShowTable.reload({
            where: {},
            page: {
                curr: 1
            }
        });
    };

    // 个人已办执行查询
    function denoSearch() {

        denoShowTable.reload({
            where: {},
            page: {
                curr: 1
            }
        });
    };

    function texLength1(obj, id) {
        var curr = obj.value.length;
        if (curr > maxlength) {
            layer.msg('反馈内容字数在' + maxlength + '字以内');
        } else {
            document.getElementById(id).innerHTML = curr;
        }
    }

    function texLength2(obj, id) {
        var curr = obj.value.length;
        if (curr > maxlength) {
            layer.msg('推送原因字数在' + maxlength + '字以内');
        } else {
            document.getElementById(id).innerHTML = curr;
        }
    };

    function back() {
        waitSearch();
        denoSearch();
        $("#inspectionHearInfo").hide();
        $(".table_div").show();
        $(".operation").hide();
    }

    function view(id, data) {

        var _id = data.id;
        var _type = data.type;
        $("#content2and3Div").html("");
        $("#_logid").val(_id);
        var mapArr = {
            id: _id,
        };
        CoreUtil.sendPost("/workflow/log/view", mapArr, function (res) {
            if (res.code == '0') {
                if (_type == "1") {
                    // 日常日志
                    var worklogInfo = res.data[0];
                    $("#content1").html(worklogInfo.content1);
                    $("#denoWorkDiv").show();
                } else if (_type == "2") {
                    $("#denoWorkDiv").hide();
                    // 案卷日志
                    var inspectionhearInfo = res.data[1];
                    var _data = res.data[2];
                    if (!CoreUtil.isEmpty(inspectionhearInfo)) {

                        $("#content2and3Div").show();
                        $("#inspectionHearInfo").show();

                        $("#jcajbh").html("案件编号：" + inspectionhearInfo.jcajbh);
                        $("#_jcajxxuuid").val(inspectionhearInfo.jcajxxuuid);
                        $("#ajmc").val(inspectionhearInfo.ajmc);
                        $("#jcxm").val(inspectionhearInfo.jcxm);
                        $("#nsrmc").val(inspectionhearInfo.nsrmc);
                        $("#nsrsbh").val(inspectionhearInfo.nsrsbh);
                        $("#jcry").val(inspectionhearInfo.jcry);

                    } else {
                        $("#content2and3Div").hide();
                        $("#inspectionHearInfo").hide();
                    }
                    // 加载模板
                    var viewSurveyTmp = "";
                    for (var _i in _data) {
                        var _optionsConent = _data[_i].optionsFeedback;

                        var _optionsTitle = _data[_i].optionsTitle;
                        var _optionsType = _data[_i].optionsType;
                        var _id = _data[_i].id;

                        if (_optionsType == "1") {
                            // 文本
                            viewSurveyTmp += "<div class='layui-form-item'>"
                                + "<label style='' class='layui-form-label'>" + _optionsTitle + "</label>"
                                + "<div class='layui-input-block'>"
                                + "<input disabled='ture' type='text' class='layui-unselect  layui-input " + _id + "' value='" + _optionsConent + "'>"
                                + "</div>";

                        } else if (_optionsType == "2") {
                            var _contentSurveyJson = eval("(" + _optionsConent + ")");
                            var l = Object.keys(_contentSurveyJson).length;
                            // 多选
                            viewSurveyTmp += "<div class='layui-form-item'>"
                                + "<label style='height: " + l * 60 + "px' class='layui-form-label'>" + _optionsTitle + "</label>";
                            for (var _ii in _contentSurveyJson) {

                                if (_contentSurveyJson[_ii].includes("_")) {
                                    var _contentSurveyJsonArr = _contentSurveyJson[_ii].split("_");
                                    viewSurveyTmp += "<div onclick='optionsDuoxuan(this," + _ii + ")' class='layui-form-checked layui-unselect layui-form-checkbox " + _id + "' lay-skin='primary'><div></div><i class='layui-icon layui-icon-ok'></i></div>" + _contentSurveyJsonArr[0];
                                    if (!CoreUtil.isEmpty(_contentSurveyJsonArr[1])) {
                                        viewSurveyTmp += "<input disabled='ture' style='width: 40%' type='text' class='layui-unselect layui-input " + _id + "_" + _ii + "' value='" + _contentSurveyJsonArr[1] + "'>";
                                    }

                                } else {
                                    viewSurveyTmp += "<div onclick='optionsDuoxuan(this," + _ii + ")' class='layui-form-checked layui-unselect layui-form-checkbox " + _id + "' lay-skin='primary'><div></div><i class='layui-icon layui-icon-ok'></i></div>" + _contentSurveyJson[_ii];

                                }

                                viewSurveyTmp += "<br>";

                            }
                            ;

                            viewSurveyTmp += "<hr>";

                        } else if (_optionsType == "3") {
                            // 单选
                            viewSurveyTmp += "<div class='layui-form-item'>"
                                + "<label style='height: " + l * 60 + "px' class='layui-form-label'>" + _optionsTitle + "</label>";
                            if (_optionsConent.includes("_")) {
                                var _contentSurveyJsonArr = _optionsConent.split("_");
                                viewSurveyTmp += "<div onclick='optionsDanxuan(this," + _ii + ")' class='layui-form-radioed layui-unselect layui-form-radio " + _id + "'><i class='layui-anim layui-icon layui-icon-radio'></i><div>" + _contentSurveyJsonArr[0] + "</div></div>"
                                if (!CoreUtil.isEmpty(_contentSurveyJsonArr[1])) {
                                    viewSurveyTmp += "<input disabled='ture' style='width: 40%' type='text' class='layui-input layui-disabled " + _id + "_" + _ii + "' value='" + _contentSurveyJsonArr[1] + "'>";
                                }
                            } else {
                                viewSurveyTmp += "<div onclick='optionsDanxuan(this," + _ii + ")' class='layui-form-radioed layui-unselect layui-form-radio " + _id + "'><i class='layui-anim layui-icon layui-icon-radio'></i><div>" + _optionsConent + "</div></div>"
                            }


                            viewSurveyTmp += "<br>";
                            viewSurveyTmp += "<hr>";

                        }
                    }
                    $("#content2and3Div").html(viewSurveyTmp);
                }

                $(".operation").show();
                $(".table_div").hide();

            } else {
                layer.msg(res.msg);
                return false;

            }
        });
    }

</script>

</body>
</html>